/*
* Copyright (C) 2020 ~ 2024 chaigec All Rights Reserved.
*
* Author:     chaigec <chaigec@163.com>
* Maintainer: chaigec <chaigec@163.com>

 * Use of this source code is governed by MIT license that can be found in the
 * LICENSE file in the root of the source tree. All contributing project authors
 * may be found in the AUTHORS file in the root of the source tree.
*/

#ifndef MK_RTMP_UT_H
#define MK_RTMP_UT_H
#include "MkMedia/MkMediaUtil.h"
#include "MkGb28181/MkGb28181.h"
#include "MkUtil/MkLock.h"
#include <gtest/gtest.h>


typedef struct _catalog_item
{
    MkString Address;
    MkString CivilCode;
    MkString DeviceID;
    MkString Manufacturer;
    MkString Model;
    MkString Name;
    MkString Owner;
    MkString ParentID;
    MkString Parental;
    MkString RegisterWay;
    MkString SafetyWay;
    MkString Secrecy;
    MkString Status;
}MkGbCatalogItem;

typedef struct _cruise_point
{
    MkString    CruisePreindex;
    MkString    CruiseStayTime;
    MkString    CruiseSpeed;
}MkGbCruisePoint;

typedef struct _cruise_track
{
    MkString                            CruiseId;
    MkString                            CruiseName;
    MkMap<MkString, MkGbCruisePoint>     MapCruiseTrack;  //key preset index 
}MkCruiseTrack;

typedef MkFunction<void()> MkRegCallback;
class CMkGb28181Test: public CMkGb28181
{
public:
    CMkGb28181Test(CMkEventPool* pEventPool, CMkTimer* pTimer);
    ~CMkGb28181Test();
    Uint32 Start(const MkGbStartParam& Param);
    Uint32 RegisterServer(const CMkGbDeviceAuthorRequest& Req,const MkRegCallback& Cb);
protected:
private:
    Uint32 OnGbRequest(const CMkGbRequest* pGbReq, const MkGbResponseCallback& Cb);
    Uint32 OnGbDeviceAuthor(const CMkGbRequest* pGbReq, const MkGbResponseCallback& Cb);
    Uint32 OnGbMessageRequest(const CMkGbMessageRequest* pGbReq, const MkGbResponseCallback& Cb);
    Uint32 OnGbNotifyReqeust(const CMkGbNotifyRequest* pGbReq, const MkGbResponseCallback& Cb);
    Uint32 OnGbSubscribeRequest(const CMkGbSubscribeRequest* pGbReq, const MkGbResponseCallback& Cb);
    Uint32 OnGbInviteRequest(const CMkGbInviteReqeust* pGbReq, const MkGbResponseCallback& Cb);
    Uint32 OnGbByeRequest(const CMkGbByeReqeust* pGbReq, const MkGbResponseCallback& Cb);
    Uint32 OnGbPlayControlRequest(const CMkGbInviteInfoRequest* pGbReq, const MkGbResponseCallback& Cb);
    Uint32 KeepAliveServer();
private:
    MkString m_KeepAliveTimer;
    MkString m_RegServerId;

    MkGbMessage m_SVACEncodeConfig;
    MkGbMessage m_BasicParam;
    MkGbMessage m_SVACDecodeConfig;
    MkGbMessage m_VideoParamOpt;
    MkGbMessage m_VideoParamAttribute;
    MkGbMessage m_VideoRecordPlan;
    MkGbMessage m_VideoAlarmRecord;
    MkGbMessage m_PictureMask;
    MkGbMessage m_AlarmReport;
    MkGbMessage m_OSDConfig;
    MkGbMessage m_SnapShot;
    Uint8       m_FrameMirrorType;
    MkMapString m_MapPreset;//key preset id value preset name
    MkMap<MkString, MkCruiseTrack>   m_MapCruiseTrack;
    MkMapString     m_HomePositonParam;
    MkGbCatalogItem m_ChannelItem;
    MkGbCatalogItem m_AlarmItem;
    MkGbCatalogItem m_AudioOutItem;
    MkString    m_DeviceName;
};


class CMkEventPool;
class CMkTimer;
class CMkGbEndUser;
class CMkGb28181Ut :  public testing::Test
{
public:
    CMkGb28181Ut();
    ~CMkGb28181Ut();

    void SetUp() override;
    void TearDown() override;

    CMkEventPool*   m_pEventPool;
    CMkTimer*       m_pTimer;


    CMkGb28181Test*     m_pGbUpServer;
    CMkGb28181Test*     m_pGbCurServer;
    CMkGb28181Test*     m_pGbDevice;
    CMkGbEndUser*   m_pGbEndUser;
    void*           m_WaitHandle;

    MkString    m_UpServerId;
    MkString    m_UpServerRealm;
    Uint16      m_UpServerPort;

    MkString    m_ServerId;
    Uint16      m_ServerPort;

    MkString    m_GbRealm;
    MkString    m_EndUserId;
    Uint16          m_EndUserPort;
    MkString  m_InviteSession;
    MkString m_SubscribeId;

};



#endif